// pages/recruit/personal/mytask/mytaskdetails/mytaskdetails.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    jobList: {},
    isStop: 1,
    title: "",
    dialogShow: false,
    buttons: [{ text: '取消' }, { text: '确定' }],
    dialogtext: "",
    btntype: '',//按钮属性是取消报名还是删除记录
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const that = this;
    console.log(options.jobid)
    let jobid = options.jobid;
    let jobList = {
      jobid: "121231",
      title: "找播音专业大学生配音",
      pay: "100/一天",
      time: "2019-10-08",
      jobtype: ["黄埔", "演出", "63次浏览"],
      condition: ["完结工", "招三人", "男女不限"],
      jobcnt: "工作内容：按照团队提供的线上完成微信文案的编辑，根据团队的要求在团队每周指定天数里的工作任务结束前将文案发送给团队。薪资按文章结算，优质文章有额外的奖励。工作时间：不限。工作地点：在家。工作类型：兼职",
      worktime: {
        type: "short",
        job: "快递分练",
        date: "至少工作一个月以上",
        least: "5天",
        time: {
          type: 1,
          start: "08:30",
          end: "17:30"
        }
      },
      location: {
        lat: "32.05838",
        long: "118.79647"
      },
      companyid: 1111,
      luqu: 5,
      luqutotal: 10,
    }
    that.setData({
      jobList: jobList,
    })
  },
  edit: function(){
    const that = this;
    wx.navigateTo({
      url: '/pages/release/index/index?jobid=' + that.data.jobList.jobid,
    })
  },
  stop: function(){
    this.setData({
      isStop: 2
    })
  },
  start: function() {
    this.setData({
      isStop: 1
    })
  },
  finish: function() {
    const that = this;
    let jobid = that.data.jobList.jobid;
    //结束招聘
    let dialogtext = "人还没有招满就要提前结束吗？建议您再耐心等等哦";
    that.setData({
      title: "结束招聘",
      dialogShow: true,
      dialogtext: dialogtext,
      btntype: "finish",
    })
    
  },
  deletejob:function(){
    const that = this;
    let jobid = that.data.jobList.jobid;
    let dialogtext = "确认删除此岗位吗？删除后岗位不再显示再列表中！";
    that.setData({
      title: "删除岗位",
      dialogShow: true,
      dialogtext: dialogtext,
      btntype: "delete",
    })
  },
  rewire:function(){
    const that = this;
    wx.navigateTo({
      url: '/pages/release/index/index?jobid=' + that.data.jobList.jobid,
    })
  },
  tapDialogButton: function (e) {
    const that = this;
    let type = e.detail.index;
    if (type == 0) {
      that.setData({
        dialogShow: false,
      })
    } else {
      that.deletetype()
    }
  },
  deletetype: function () {//确定按钮的后续操作
    const that = this;
    let type = that.data.btntype;
    let deleteid = that.data.jobList.jobid;
    if (type == "finish") {//停止招聘
      that.setData({//操作成功后再删除
        dialogShow: false,
        isStop: 3
      })
    } else if (type == "delete") {//删除记录
      console.log(deleteid)
      that.setData({//操作成功后再删除
        dialogShow: false,
      })
    }
  }
})